package com.lagou.homework.modulethree;

import java.util.Arrays;

/*
 * @className First
 * @description : 作业一
 * @author admin
 * @date 2022/3/26 12:51
 * */
public class First {
    public static String toString(int[] arr) {
        if (null == arr)
            return "null";
        if (0 == arr.length)
            return "[]";
        StringBuilder sb = new StringBuilder("[");
        for (int i = 0; i < arr.length; i++) {
            sb.append(arr[i]);
            if (i == arr.length - 1) {
                sb.append("]");
            } else {
                sb.append(",");
            }

        }
        return sb.toString();
    }

    public static void main(String[] args) {
        int[] arr = null;
        int[] arr1 = new int[0];
        int[] arr2 = new int[]{1,2,3,4,5};
        System.out.println(First.toString(arr));
        System.out.println(First.toString(arr1));
        System.out.println(First.toString(arr2));
    }
}
